package com.demo.mapsocial;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class AuthenticationSettings {

	private Context context;
	private SharedPreferences settings;

	private static final String FB_ACCESS_TOKEN = "FB_ACCESS_TOKEN";
	private static final String FB_ACCESS_EXPIRES = "FB_ACCESS_EXPIRES";

	public AuthenticationSettings(Context context) {
		this.context = context;
	}

	public String getAccessToken() {
		SharedPreferences preferences = PreferenceManager
				.getDefaultSharedPreferences(context);

		return preferences.getString(FB_ACCESS_TOKEN, null);
	}

	public long getAccessExpires() {
		SharedPreferences preferences = PreferenceManager
				.getDefaultSharedPreferences(context);

		return preferences.getLong(FB_ACCESS_EXPIRES, 0);
	}

	public void setAuthenticationInfo(String accessToken, long accessExpires) {
		SharedPreferences preferences = PreferenceManager
				.getDefaultSharedPreferences(context);
		SharedPreferences.Editor edit = preferences.edit();
		
		edit.putString(FB_ACCESS_TOKEN, accessToken);
		edit.putLong(FB_ACCESS_EXPIRES, accessExpires);		
		edit.commit();
	}
}
